<?php
if (!defined('APP_PATH')) {
	define('APP_PATH', $_SERVER['DOCUMENT_ROOT']."/bdACPA");
}
require_once(APP_PATH.'/required.php');

header("Content-type:text/xml");
echo("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
$idDossiers = explode("|",$_REQUEST["idDossiers"]);
$out = "<rows>";
foreach ($idDossiers as $idDossier){
	if (trim($idDossier)!= null){
		$dossier = $DOSSIER_DAO->recupere_dossier_par_id_pour_tableau_recherche($idDossier);
		if ($dossier != null){
		$out .= "<row id = '".$dossier[0]["iddossier"].".' >";
		$out .= "<cell>false</cell>";
		$out .= "<cell>".$dossier[0]["iddossier"]."</cell>";
		$out .= "<cell>".$dossier[0]["numero"]."</cell>";
		$out .= "<cell>".$dossier[0]["sexe"]."</cell>";
		$out .= "<cell>".$dossier[0]["categorie"]."</cell>";
		$phenotypes = $PHENOTYPE_DAO->rechercher_phenotypeByDossier($idDossier);
		if (count($phenotypes)==0){
			$pheno = "non renseigné";
		} else {
				$pheno = "";
				foreach ($phenotypes as $phenotype){
					if ($phenotype["libelle"] == "Autre"){
						$pheno .= $phenotype["precision"].", ";
					} else {
						$pheno .= $phenotype["libelle"].", ";
					}
					
				}
		}
		$pheno .= $dossier[0]["autrephenotype"];
		$out .= "<cell>".$pheno."</cell>";
		$out .= "<cell>".$dossier[0]["typeprelevement"]."</cell>";
		$out .= "<cell>".$dossier[0]["marquepuce"]."</cell>";
		$out .= "<cell>".$dossier[0]["typepuce"]."</cell>";
		$out .= "<cell>".$dossier[0]["nbcnv"]."</cell>";
		$out .= "<cell>".$dossier[0]["formulechromosomique"]."</cell>";
		$out .= "<cell>".$dossier[0]["centre"]."</cell>";
		$out .= "</row>";
		}
	}
}
$out .= "</rows>";
print($out);
?>